/*
============================================================================
 Name        : PlayerPlugin.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CPlayerPlugin declaration
============================================================================
*/

#ifndef __PLAYERPLUGIN_H__
#define __PLAYERPLUGIN_H__

// INCLUDES
#include <e32std.h>
#include <e32base.h>

#include <mdaaudiosampleplayer.h>

#include "PluginInterface.h"
#include "MPluginAdapter.h"

class CMdaAudioPlayerUtility;
class CEikMenuPane;

class CPlayerPlugin :	public CPluginInterface, 
						public MMdaAudioPlayerCallback
{
public: // Constructors and destructor
	~CPlayerPlugin();
	static CPlayerPlugin* NewL();
	static CPlayerPlugin* NewLC();

private:
	CPlayerPlugin();
	void ConstructL();


public: //from CPluginInterface
	const TDesC& GetMenuText();
	TInt GetMenuCommand();
	void AddExtraMenu(CEikMenuPane* aMenuPane);
	void HandleCommandL(TInt aCommand);
	void Draw(CWindowGc& aGc, const TRect& aRect) const;

	void Activate();
	void Deactivate();

	//Colors
	TRgb BackBorderColor() const { return TRgb(0x103868); }
	TRgb BackShadowColor() const { return TRgb(0x6888b0); }
	TRgb BackColor() const { return TRgb(0xa0c8e0); }
	TRgb InsideBorderColor() const { return TRgb(0x486888); }
	TRgb InsideColor() const { return TRgb(0xd8e8f0); }
	TRgb ForeColor() const { return InsideBorderColor(); }


public: //from MPluginAdapter
	void PlayL();
	void PauseL();
	void StopL();

	TBool IsReadyToPlay();
	TBool IsReadyToPause();
	TBool IsReadyToStop();

	TInt Volume();
	void SetVolume(TInt aVolume);


public: //from MMdaAudioPlayerCallback
	void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration );
	void MapcPlayComplete(TInt aError);


public: //new functions
	void OpenFileL();


private: //new functions
	void OpenCurrentFileL();
	void ShowMetadataL();


private: //data
	//State
	enum TState
	{
		EStateNotReady,		//Not ready to play
		EStateReadyToPlay,	//Ready to play
		EStatePlaying,		//Playing
		EStatePaused		//Paused
	} iState;

	// The audio player utility object
	CMdaAudioPlayerUtility* iMdaAudioPlayerUtility;

	//Bitmaps
	RPointerArray<CFbsBitmap> iBitmaps;

	//Volume
	TInt iVolume;
	TInt iVolumeFactor;

	//Metadata
	TBuf<500> iMetadata;

	//Current filename
	TFileName iFileName;
};

#endif // PLAYERPLUGIN_H
